<!--页面主要内容-->
<main class="lyear-layout-content">

    <div class="container-fluid p-t-15">

        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">

                        <form method="post" class="row" >
                            <div class="form-group col-md-12">
                                <label for="name">配送公司名称</label>
                                <input type="text" class="form-control" id="name" name="name" value="{$expressData.name}"
                                    placeholder="请输入分类名称" />
                            </div>
                            <div class="form-group col-md-12">
                                <label for="prename">配送公司单号前缀</label>
                                <input type="text" class="form-control" id="prename" name="prename" min="1" value="{$expressData.prename}"
                                    placeholder="配置的数值" />
                            </div>
                            <div class="form-group col-md-12">
                                <button type="submit" class="btn btn-primary ajax-post"
                                    target-form="add-form">更新</button>
                                <button type="button" class="btn btn-default"
                                    onclick="javascript:history.back(-1);return false;">返 回</button>
                            </div>
                        </form>

                    </div>
                </div>
            </div>

        </div>

    </div>

</main>
<!--End 页面主要内容-->
<script>
    layui.use(['layer'], function () {
        let $ = layui.jquery,
            layer = layui.layer
            $('input[name="name"]').change(function () {
            let newName = `{$expressData['name']}`;
            let name = $(this).val();
           if(newName != name){
                //发起请求
                $.ajax({
                    type: 'post',
                    url: `{:url('admin/express/expressadd')}`,
                    data: {
                        name,
                        action: "name"
                    },
                    dataType: 'json',
                    success: function (res) {
                        if (res.code === 1) {
                            layer.msg(res.msg, { icon: 1 })
                        } else {
                            layer.msg(res.msg, { icon: 0 })
                        }
                    }
                })
            }
        })    
    })
   
</script>